input FILEIO;

outputtemplate := "%j-%03c.eps";
outputformat := "eps";
%outputtemplate := "%j-%03c.svg";
%outputformat := "svg";

prologues := 3;
w = 0.5 mm;
u = 20.0 w;

ahlength := 0.4 u;
ahangle := 36;

def tr (expr a) =
	((a) scaled u yscaled 1)
enddef;

def process (expr f) = begingroup
	numeric n, prev, curr;
	read_line (f);
	n := get_num;

	prev := 0;
	read_line (f);
	for i := 1 upto n:
		show i;
		show buf;
		curr := get_num;
		show curr;
		pickup pencircle scaled 1.0 w;
		drawarrow tr ((prev, 0.1){up} ...
		    (0.5 * (prev + curr), 0.4) ... {down}(curr, 0.1));
		pickup pencircle scaled 1.0 w;
		draw fullcircle scaled 0.24 shifted tr ((curr, 0));
		prev := curr;
	endfor;

	pickup pencircle scaled 1.0 w;
	for i := 0 upto curr:
		draw tr ((i, 0.0) -- (i, 0.3));
	endfor;

	pickup pencircle scaled 2.0 w;
	draw tr ((0, 0) -- (curr, 0));

	read_line (f); % EOF
endgroup enddef;

beginfig (1)
	process ("001.input");
	currentpicture := currentpicture shifted -llcorner (currentpicture);
endfig;

beginfig (2)
	process ("002.input");
	currentpicture := currentpicture shifted -llcorner (currentpicture);
endfig;

end.
